#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long ll;
int main() {
    int n;
    scanf("%d", &n);
    ll a1[n][n];
    ll a2[n][n];
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++)
            scanf("%lld", &a1[i][j]);
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++)
            scanf("%lld", &a2[i][j]);
    ll res[n][n];
    ll result;
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            result=0;
            for (int k=0; k<n; k++) {
                result+=a1[i][k]*a2[k][j];
            }
            res[i][j]=result;
            printf ("%lld ", res[i][j]);
        }
        printf("\n");
    }
    return 0;
}
